// import {createStore, combineReducers} from 'redux'
// import { createBrowserHistory } from 'history'
// const history = createBrowserHistory()
//
// // 对外输出一个to的接口,当一个模块需要跳转界面的时候,会向所有的模块调用这个接口,
// // 然后对应的模块会直接渲染到正确的页面
// function to(state, action) {
//     if (action.type !== 'to') return {...state, path: action.path}
//     history.replace(action.path)
//     return {...state, path: action.path}
// }
//
// export const storeInstance = createStore(combineReducers({namespace: () => 'base', to}))
//
// export {history}

// this.$reduxStore.globalEventDistributor.dispatch({type: 'MODIFY_THEME', theme:"red"})
// let tes = this.$globalStore && this.$globalStore.dispatch({type: 'MODIFY_THEME', theme:"red"})
// let val = this.$globalStore && this.$globalStore.getState("base").render.theme

import { createStore, combineReducers } from 'redux'
const initialState = {
  theme: 'white'
}
function render (state = initialState, action) {
  switch (action.type) {
    case 'MODIFY_THEME':
      console.log('---MODIFY_THEME---', state.theme)
      return {
        ...state,
        theme: action.theme
      }
    case 'MODIFY_I18N':
      console.log('---MODIFY_I18N---', state.theme)
      return { ...state,
        theme: 'I18N'
      }
    default:
      return state
  }
}
// 向外输出 Store
export const storeInstance = createStore(combineReducers({ namespace: () => 'base', render }))
